﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Configuration;
using System.Configuration;

namespace Microsoft.Cryptography.WCF
{
    /// <summary>
    /// Use this class in configuration files when you want to use the <see cref="Microsoft.Cryptography.WCF.ServiceCredentials" />
    /// </summary>
    public class ServiceCredentialsConfigHandler : ServiceCredentialsElement, System.ServiceModel.Description.IServiceBehavior
    {
        /// <summary>
        /// Returns the type of the <see cref="Microsoft.Cryptography.WCF.ServiceCredentialsConfigHandler" />
        /// </summary>
        public override Type BehaviorType
        {
            get { return typeof(ServiceCredentialsConfigHandler); }
        }

        /// <summary>
        /// Returns the <see cref="Microsoft.Cryptography.WCF.ServiceCredentials" />
        /// </summary>
        /// <returns>Returns the <see cref="Microsoft.Cryptography.WCF.ServiceCredentials" /></returns>
        protected override object CreateBehavior()
        {
            ServiceCredentials creds = new ServiceCredentials();
            base.ApplyConfiguration(creds);
            
            return creds;
        }


        #region IServiceBehavior Members

        void System.ServiceModel.Description.IServiceBehavior.AddBindingParameters(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<System.ServiceModel.Description.ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
        {
        }

        void System.ServiceModel.Description.IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
        }

        void System.ServiceModel.Description.IServiceBehavior.Validate(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
        }

        #endregion
    }
}

